package com.frank.multiDatasource.service;

import com.frank.multiDatasource.annotation.DS;
import com.frank.multiDatasource.constants.DataSourceConstants;
import com.frank.multiDatasource.entity.TestUser;
import com.frank.multiDatasource.mapper.TestUserRepository;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 小石潭记
 * @date 2020/10/27 14:31
 * @Description: ${todo}
 */
@DS(DataSourceConstants.DS_KEY_SLAVE)
public class TestUserClassService {
    @Autowired
    private TestUserRepository testUserMapper;

    /**
     * 查询slave库User
     * @return
     */
    public List<TestUser> getSlaveUser(){
        Iterable<TestUser> all = testUserMapper.findAll();
        List<TestUser> list = new ArrayList<>();
        all.forEach(item -> {
            list.add(item);
        });
        return list;
    }
}
